package com.example.adms.attendance.controller;

import com.example.adms.attendance.dto.*;
import com.example.adms.attendance.service.AttendanceService;
import com.example.adms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/attendance")
public class AttendanceController {

    @Autowired
    private AttendanceService attendanceService;


    /**
     * 签到处理
     * @param onParams
     * @return
     */
    @PostMapping("/on")
    public Result on(@RequestBody OnParams onParams){
        return attendanceService.onHandle(onParams);
    }

    /**
     * 签退处理
     * @param offParams
     * @return
     */
    @PostMapping("/off")
    public Result off(@RequestBody OffParams offParams){
        return attendanceService.offHandle(offParams);
    }


    /**
     * 个人考勤信息查询
     * @param oneAttQueryParams
     * @return
     */
    @PostMapping("/getAttendanceForOne")
    public Result getAttendanceForOne(@RequestBody OneAttQueryParams oneAttQueryParams){
        return attendanceService.getAttendanceForOne(oneAttQueryParams);
    }

    /**
     * 所有人考勤信息查询
     * @param allAttQueryParams
     * @return
     */
    @PostMapping("/getAttendanceForAll")
    public Result getAttendanceForAll(@RequestBody AllAttQueryParams allAttQueryParams){
        return attendanceService.getAttendanceForAll(allAttQueryParams);
    }

    /**
     * 统计某月各部门的迟到早退情况
     * @param month
     * @return
     */
    @GetMapping("/getTotalAttendance")
    public Result getTotalAttendance(Integer month){
        return attendanceService.getTotalAttendance(month);
    }

    /**
     * 获取每月迟到最多的员工
     * @param month
     * @return
     */
    @GetMapping("/getMostLate")
    public Result getMostLate(Integer month){
        return attendanceService.getMostLate(month);
    }

    /**
     * 获取每月早退最多的员工
     * @param month
     * @return
     */
    @GetMapping("/getMostEarly")
    public Result getEarly(Integer month){
        return attendanceService.getMostEarly(month);
    }
}
